package com.edu.exam.enums.curriculum.questionbank;

/**
 * 题目状态枚举
 *
 * 试题状态定义
 *
 * @author System
 * @version 1.0.0
 */
public enum QuestionStatus {
    DRAFT("DRAFT", "草稿"),
    PUBLISHED("PUBLISHED", "已发布"),
    ARCHIVED("ARCHIVED", "已归档"),
    UNDER_REVIEW("UNDER_REVIEW", "审核中"),
    REJECTED("REJECTED", "已拒绝");

    private final String code;
    private final String description;

    QuestionStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据代码获取枚举值
     *
     * @param code 代码
     * @return 对应的枚举值
     */
    public static QuestionStatus fromCode(String code) {
        for (QuestionStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return DRAFT; // 默认值
    }
}